<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Progma" content="no-cache" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/mm_training.css" type="text/css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/user.css" type="text/css" />
<link type="text/css" href="<%=request.getContextPath() %>/css/smoothness/jquery-ui-1.7.1.custom.css" rel="stylesheet"/>
<script type="text/javascript" src="<%=request.getContextPath() %>/scripts/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/scripts/jquery/jquery-ui-1.7.1.custom.js"></script>
<script type="text/javascript">
	/**
	 * 
	 * 修改密碼
	 *
	 */ 
	function changeMobile() {
		var context = '<%=request.getContextPath()%>';
		// 獲取登陸數據
		var params = $("#changeForm").serialize();
		// 請求開始時提示消息
		$("#loading").ajaxStart(function(){
			   $(this).dialog({
				   title:"正在綁定手機號碼,請稍等.......",
				   modal:true,
				   height:0,
				   resizable:false,
				   draggable:false
			   });
		});
		// 請求完成
		 $("#loading").ajaxComplete(function(request, settings){
			 $(this).dialog("destroy");
		});
		// 提交請求
		$.ajax({
			   url: context + "/setup/bindingMobileAgain.do",
			   data: params,
			   dataType:"html",
			   success: function (data) {
					// 清除所有錯誤消息 
				   $("span[id^='err_msg_']").each(function (index) {
					   // 清空錯誤消息
					   $(this).text("");
				   });
				   var errorMessage = $("li",data);
				   // 獲取返回消息 
				   var returnMessage = $("#returnMessage", data);
				   // 如果存在錯誤消息
				   if (errorMessage.length > 0) {
					   // 獲取消息
					   errorMessage.each(function (index) {
							// 獲取發生錯誤的字段ID
						   var id = $(this).attr("id");
						   // 獲取錯誤消息
						   var value = $(this).text();
						   // 顯示錯誤消息地方
						   var errorID = "err_msg_" + id;
						   // 設置錯誤消息
						   $("#" + errorID).text(value);
					   });
				   } else if (returnMessage.length > 0) {
						$("<div></div>").html(returnMessage.text()).dialog({
							title:returnMessage.text(),
							resizable:false,
							draggable:false
						});
						// 清空文本框,密碼輸入框 
						$(":text,:password").each(function (index){
							$(this).val("");
						});
				   }
			   },
		   	   error: function (data) {
			   	   document.location.href = context + "/error.jsp?random=" + Math.random();
			   }
		});
		// 不提交表单
		return false;
	}

	/**
	 *
	 * 獲取手機驗證碼 
	 *
	 */
	function getMobileAuthCode() {
		$("<div>獲取手機驗證碼</div>").dialog({
			title: '獲取手機驗證碼',
			resizable: false,
			draggable: false
		});
	}
</script>

<style type="text/css">
	.sidebarText {
	}
	.err_msg {
		color: red;
		font-size: 12px;
	}
	body {
		font-size: 12px;
	}
</style>
<title>關聯手機號碼變更</title>
</head>
<body bgcolor="#64748B">
<jsp:include page="/head.jsp"></jsp:include>
	<td width="230" valign="top" bgcolor="#26354a" colspan="2">
		<table width="230" cellspacing="0" cellpadding="0" border="0">
			<tbody>
			<s:if test="('company'.equals(userType) && 'parentManager'.equals(managerLevel)) || 'company'.equals(person)">
				<tr>
					<td width="230" id="padding" class="sidebarText"><a href="<%=request.getContextPath()%>/setup/account.do">修改我的個人資料</a><br/>
					<br/></td>
				</tr>
				<tr>
					<td width="230" id="padding" class="sidebarText"><a href="<%=request.getContextPath()%>/setup/changeMobileAction.do">關聯手機號碼變更</a><br/>
					<br/></td>
				</tr>
			</s:if>
			<s:if test="'company'.equals(userType) && 'parentManager'.equals(managerLevel)">
				<tr>
					<td width="230" id="padding" class="sidebarText"><a href="<%=request.getContextPath()%>/setup/goSubAccount.do">增加一個管理帳號</a><br />
					<br />
					</td>
				</tr>
				<tr>
					<td width="230" id="padding" class="sidebarText"><a href="<%=request.getContextPath() %>/setup/subAccountManage.do">子帳號管理</a><br />
					<br />
					</td>
				</tr>
			</s:if>
			<s:if test="('company'.equals(userType) && 'parentManager'.equals(managerLevel)) || 'person'.equals(userType)">
				<tr>
					<td width="230" id="padding" class="sidebarText"><a href="<%=request.getContextPath()%>/setup/wallet.do">錢包設置</a><br/>
					<br/></td>
				</tr>
			</s:if>
		</tbody>
		</table>
	</td>
	<td valign="top" width='100%'>
		<form id="changeForm" action="<%=request.getContextPath() %>/setup/bindingMobileAgain.do" method="post">
			<div id="pagetest" style="border:1px solid #DADADA;min-width:700px;">
				<table width="100%" cellspacing="0" cellpadding="0" border="0">
					<tbody>
						<tr>
						<td class="sidebarText" width="20%" align="right">錄入你的密碼
						</td>
						<td align="left">
						<input type="password" id="oldpass" name="oldpass" size="15" maxlength="15"/><span id="err_msg_oldpass" class="err_msg"></span>
						</td>
						</tr>
						<tr>
						<td class="sidebarText" align="right">錄入新的手機號碼
						</td>
						<td align="left">
						<input type="text" id="newmobile" name="newmobile" size="15" maxlength="10"/><span id="err_msg_newmobile" class="err_msg"></span>
						</td>
						</tr>
						<tr>
						<td class="sidebarText" align="right">錄入收到的驗證碼
						</td>
						<td align="left">
						<input type="text" id="authcode" name="authcode" size="4" maxlength="4"/><span id="err_msg_authcode" class="err_msg"></span>
						<input type="button" name="change" value="獲取手機驗證碼" onclick="getMobileAuthCode();"/>
						</td>
						</tr>
						<tr>
						<td align="center" colspan="2">
							<input type="button" name="change" value="修改" onclick="changeMobile();"/>
						</td>
						</tr>
					</tbody>
				</table>
			</div>
		</form>
	</td>
	<div id="loading" style="color: red; display: none;">loading........</div>
<jsp:include page="/footer.jsp"></jsp:include>
</body>
</html>